print("haha-lr插件，版本：0.0.1.202501122000")

local wowWatcher = CreateFrame("Frame", "BlueSquareFrame", UIParent);-- 创建一个新的框架
wowWatcher:SetFrameLevel(1);-- 设置框架的层级
wowWatcher:SetSize(100, 100) -- 宽度和高度都是100像素 -- 设置框架的尺寸
wowWatcher:SetPoint("TOPLEFT", UIParent, "TOPLEFT", 0, 0) -- 距离屏幕左上角10,-10的位置 -- 设置框架的位置

-- 从左到右，颜色对应的含义
-- 1-1 单体开关，绿色为开,红色为关
-- 1-2 AOE开关，绿色为开，红色为关，预留位置，暂时没有
-- 1-3 裂伤（豹），绿色为需要打，红色为不需要打
-- 1-4 野蛮咆哮，绿色为需要打，红色为不需要打
-- 1-5 斜掠，绿色为需要打，红色为不需要打
-- 1-6 撕碎，绿色为需要打，红色为不需要打
-- 1-7 割裂，绿色为需要打，红色为不需要打
-- 1-8
-- 1-9

local colorSize = 5;

-- 1-1 单体开关，绿色为开,红色为关
local one_target_switch_wl_green = wowWatcher:CreateTexture(nil, "BACKGROUND")
one_target_switch_wl_green:SetColorTexture(0, 1, 0, 1)
one_target_switch_wl_green:SetPoint("TOPLEFT", wowWatcher, "TOPLEFT", 0, 0); -- 使纹理填充整个框架
one_target_switch_wl_green:SetSize(colorSize, colorSize);
one_target_switch_wl_green:SetAlpha(0);

local one_target_switch_wl_red = wowWatcher:CreateTexture(nil, "BACKGROUND")--创建纹理
one_target_switch_wl_red:SetColorTexture(1, 0, 0, 1)
one_target_switch_wl_red:SetPoint("TOPLEFT", wowWatcher, "TOPLEFT", 0, 0);--设置框架相对锚点
one_target_switch_wl_red:SetSize(5, 5)
one_target_switch_wl_red:SetAlpha(1)

-- 间隔纹理
local splitTexture6 = wowWatcher:CreateTexture(nil, "BACKGROUND")
splitTexture6:SetColorTexture(0.5, 0.5, 0.5, 1)
splitTexture6:SetPoint("TOPLEFT", wowWatcher, "TOPLEFT", 5, 0); -- 使纹理填充整个框架
splitTexture6:SetSize(1, colorSize);
splitTexture6:SetAlpha(1);

-- 1-2 AOE开关，绿色为开，红色为关，预留位置，暂时没有
local more_target_switch_wl_green = wowWatcher:CreateTexture(nil, "BACKGROUND")
more_target_switch_wl_green:SetColorTexture(0, 1, 0, 1)
more_target_switch_wl_green:SetPoint("TOPLEFT", wowWatcher, "TOPLEFT", 6, 0); -- 使纹理填充整个框架
more_target_switch_wl_green:SetSize(colorSize, colorSize);
more_target_switch_wl_green:SetAlpha(0);

local more_target_switch_wl_red = wowWatcher:CreateTexture(nil, "BACKGROUND")--创建纹理
more_target_switch_wl_red:SetColorTexture(1, 0, 0, 1)
more_target_switch_wl_red:SetPoint("TOPLEFT", wowWatcher, "TOPLEFT", 6, 0);--设置框架相对锚点
more_target_switch_wl_red:SetSize(5, 5)
more_target_switch_wl_red:SetAlpha(1)

-- 间隔纹理
local splitTexture7 = wowWatcher:CreateTexture(nil, "BACKGROUND")
splitTexture7:SetColorTexture(0.5, 0.5, 0.5, 1)
splitTexture7:SetPoint("TOPLEFT", wowWatcher, "TOPLEFT", 11, 0); -- 使纹理填充整个框架
splitTexture7:SetSize(1, colorSize);
splitTexture7:SetAlpha(1);

-- 1-3 裂伤（豹），绿色为需要打，红色为不需要打
local ls_green = wowWatcher:CreateTexture(nil, "BACKGROUND")
ls_green:SetColorTexture(0, 1, 0, 1)
ls_green:SetPoint("TOPLEFT", wowWatcher, "TOPLEFT", 12, 0);
ls_green:SetSize(colorSize, colorSize);
ls_green:SetAlpha(0);

local ls_red = wowWatcher:CreateTexture(nil, "BACKGROUND")
ls_red:SetColorTexture(1, 0, 0, 1)
ls_red:SetPoint("TOPLEFT", wowWatcher, "TOPLEFT", 12, 0);
ls_red:SetSize(colorSize, colorSize)
ls_red:SetAlpha(1)

-- 间隔纹理
local splitTexture1 = wowWatcher:CreateTexture(nil, "BACKGROUND")
splitTexture1:SetColorTexture(0.5, 0.5, 0.5, 1)
splitTexture1:SetPoint("TOPLEFT", wowWatcher, "TOPLEFT", 17, 0);
splitTexture1:SetSize(1, colorSize);
splitTexture1:SetAlpha(1);

-- 1-2 焦点腐蚀术，红色不打，绿色打
local focus_fss_green = wowWatcher:CreateTexture(nil, "BACKGROUND")
focus_fss_green:SetColorTexture(0, 1, 0, 1)
focus_fss_green:SetPoint("TOPLEFT", wowWatcher, "TOPLEFT", 18, 0);
focus_fss_green:SetSize(colorSize, colorSize);
focus_fss_green:SetAlpha(0);

local focus_fss_red = wowWatcher:CreateTexture(nil, "BACKGROUND")
focus_fss_red:SetColorTexture(1, 0, 0, 1)
focus_fss_red:SetPoint("TOPLEFT", wowWatcher, "TOPLEFT", 18, 0);
focus_fss_red:SetSize(colorSize, colorSize)
focus_fss_red:SetAlpha(1)

-- 间隔纹理
local splitTexture2 = wowWatcher:CreateTexture(nil, "BACKGROUND")
splitTexture2:SetColorTexture(0.5, 0.5, 0.5, 1)
splitTexture2:SetPoint("TOPLEFT", wowWatcher, "TOPLEFT", 23, 0);
splitTexture2:SetSize(1, colorSize);
splitTexture2:SetAlpha(1);

-- 1-3 主目标暗影箭，红色不打，绿色打
local target_ayj_green = wowWatcher:CreateTexture(nil, "BACKGROUND")
target_ayj_green:SetColorTexture(0, 1, 0, 1)
target_ayj_green:SetPoint("TOPLEFT", wowWatcher, "TOPLEFT", 24, 0);
target_ayj_green:SetSize(colorSize, colorSize);
target_ayj_green:SetAlpha(0);

local target_ayj_red = wowWatcher:CreateTexture(nil, "BACKGROUND")
target_ayj_red:SetColorTexture(1, 0, 0, 1)
target_ayj_red:SetPoint("TOPLEFT", wowWatcher, "TOPLEFT", 24, 0);
target_ayj_red:SetSize(colorSize, colorSize)
target_ayj_red:SetAlpha(1)

-- 间隔纹理
local splitTexture3 = wowWatcher:CreateTexture(nil, "BACKGROUND")
splitTexture3:SetColorTexture(0.5, 0.5, 0.5, 1)
splitTexture3:SetPoint("TOPLEFT", wowWatcher, "TOPLEFT", 29, 0);
splitTexture3:SetSize(1, colorSize);
splitTexture3:SetAlpha(1);

-- 1-4 焦点暗影箭，红色不打，绿色打
local focus_ayj_green = wowWatcher:CreateTexture(nil, "BACKGROUND")
focus_ayj_green:SetColorTexture(0, 1, 0, 1)
focus_ayj_green:SetPoint("TOPLEFT", wowWatcher, "TOPLEFT", 30, 0);
focus_ayj_green:SetSize(colorSize, colorSize);
focus_ayj_green:SetAlpha(0);

local focus_ayj_red = wowWatcher:CreateTexture(nil, "BACKGROUND")
focus_ayj_red:SetColorTexture(1, 0, 0, 1)
focus_ayj_red:SetPoint("TOPLEFT", wowWatcher, "TOPLEFT", 30, 0);
focus_ayj_red:SetSize(colorSize, colorSize)
focus_ayj_red:SetAlpha(1)

-- 间隔纹理
local splitTexture4 = wowWatcher:CreateTexture(nil, "BACKGROUND")
splitTexture4:SetColorTexture(0.5, 0.5, 0.5, 1)
splitTexture4:SetPoint("TOPLEFT", wowWatcher, "TOPLEFT", 35, 0);
splitTexture4:SetSize(1, colorSize);
splitTexture4:SetAlpha(1);

-- 1-5 鬼影缠身的颜色
local gycs_wl_green = wowWatcher:CreateTexture(nil, "BACKGROUND")
gycs_wl_green:SetColorTexture(0, 1, 0, 1)
gycs_wl_green:SetPoint("TOPLEFT", wowWatcher, "TOPLEFT", 36, 0); -- 使纹理填充整个框架
gycs_wl_green:SetSize(5, 5);
gycs_wl_green:SetAlpha(0);

local gycs_wl_red = wowWatcher:CreateTexture(nil, "BACKGROUND")--创建纹理
gycs_wl_red:SetColorTexture(1, 0, 0, 1)
gycs_wl_red:SetPoint("TOPLEFT", wowWatcher, "TOPLEFT", 36, 0);--设置框架相对锚点
gycs_wl_red:SetSize(5, 5)
gycs_wl_red:SetAlpha(1);

-- 间隔纹理
local splitTexture5 = wowWatcher:CreateTexture(nil, "BACKGROUND")
splitTexture5:SetColorTexture(0.5, 0.5, 0.5, 1)
splitTexture5:SetPoint("TOPLEFT", wowWatcher, "TOPLEFT", 41, 0); -- 使纹理填充整个框架
splitTexture5:SetSize(1, colorSize);
splitTexture5:SetAlpha(1);

-- 工具函数区
-- 这段是一个独立的方法，可以被其他地方调用，用来获取目标身上的debuff信息，并封装到对象列表中
local function getDebuff(player, filter)
    if filter == nil then
        filter = "HARMFUL";
    end
    local debuffList = {}
    --读取对象身上的有害buff
    for i = 1, 40 do
        local name, icon, count, dispelType, duration, expirationTime, source, isStealable, nameplateShowPersonal, spellId, canApplyAura, isBossDebuff, castByPlayer = UnitAura(player, i, filter)
        if name then
            table.insert(debuffList, createDebuffInfo(name, count, expirationTime, source, castByPlayer, spellId, canApplyAura));
        else
            break
        end
    end
    return debuffList
end

-- 这段代码是用来创建debuff的对象，保存了名称和过期的时间
function createDebuffInfo(name, count, expirationTime, source, castByPlayer, spellId, canApplyAura)
    return {
        name = name,
        count = count,
        expirationTime = expirationTime,
        source = source,
        castByPlayer = castByPlayer,
        spellId = spellId,
        canApplyAura = canApplyAura
    }
end

-- 变量区
-- 用于表示当前是否有目标
local hasTarget = false;
-- 用于检测当前目标是否可以被攻击
local canAttack = false;
-- 检测当前目标是否已经死亡
local targetIsDead = false;

-- 事件区
wowWatcher:SetScript("OnUpdate", function()

end);

-- 单目标输出打开
function startOneTargetSwitch()
    one_target_switch_wl_red:SetAlpha(0);
    one_target_switch_wl_green:SetAlpha(1);

    more_target_switch_wl_red:SetAlpha(1);
    more_target_switch_wl_green:SetAlpha(0);
end

-- 多目标输出打开
function startMoreTargetSwitch()
    more_target_switch_wl_red:SetAlpha(0);
    more_target_switch_wl_green:SetAlpha(1);

    one_target_switch_wl_red:SetAlpha(1);
    one_target_switch_wl_green:SetAlpha(0);
end

-- 关闭所有输出
function closeSwitch()
    -- 关闭单体输出
    one_target_switch_wl_red:SetAlpha(1);
    one_target_switch_wl_green:SetAlpha(0);

    more_target_switch_wl_red:SetAlpha(1);
    more_target_switch_wl_green:SetAlpha(0);
end